# Contributor: Matt Dainty <matt+alpine@bodgit-n-scarper.com>
# Contributor: Dermot Bradley <dermot_bradley@yahoo.com>
# Maintainer: Dermot Bradley <dermot_bradley@yahoo.com>
pkgname=cloud-init
pkgver=20.2
pkgrel=0
pkgdesc="Cloud instance init scripts"
url="https://cloud-init.io"
arch="noarch"
license="Apache-2.0 OR GPL-3.0-only"
depends="blkid e2fsprogs-extra ifupdown python3 py3-configobj py3-jinja2
	py3-jsonpatch py3-jsonschema py3-oauthlib py3-requests py3-serial
	py3-six py3-yaml shadow sudo"
makedepends="py3-setuptools"
subpackages="$pkgname-doc $pkgname-bash-completion $pkgname-openrc"
source="https://launchpad.net/cloud-init/trunk/$pkgver/+download/cloud-init-$pkgver.tar.gz
	01-add-distro-alpine.patch
	02-add-to-util.patch
	03-add-to-cloud-cfg-template.patch
	04-add-to-render-cloudcfg.patch
	05-add-ca_certs-module-support.patch
	06-add-ntp-module-support.patch
	07-add-power_state-module-support.patch
	08-add-resolv_conf-module-support.patch
	alpine.py
	cc_apk_configure.py
	chrony.conf.alpine.tmpl
	hosts.alpine.tmpl
	interfaces
	ntp.conf.alpine.tmpl
	"

prepare() {
	default_prepare

	install -m644 \
		"$srcdir"/alpine.py \
		"$builddir"/cloudinit/distros/

	install -m644 \
		"$srcdir"/cc_apk_configure.py \
		"$builddir"/cloudinit/config/
}

build() {
	python3 setup.py build
}

check() {
	python3 setup.py check
}

package() {
	python3 setup.py install \
		--prefix=/usr --root="$pkgdir" --init-system=sysvinit_openrc

	install -m644 \
		"$srcdir"/*.tmpl \
		"$pkgdir"/etc/cloud/templates/

	mkdir -p \
		"$pkgdir"/etc/network
	install -m644 \
		"$srcdir"/interfaces \
		"$pkgdir"/etc/network/

	# Delete non-Alpine distribution template files
	for distro in \
		debian fedora freebsd opensuse redhat rhel sles suse ubuntu
	do
		for file in \
			"$(ls "$pkgdir"/etc/cloud/templates/*"$distro".tmpl)"
		do
			rm $file
		done
	done

	# Delete systemd template file
	rm "$pkgdir"/etc/cloud/templates/timesyncd.conf.tmpl
}

sha512sums="2b63d435b162b6db232121959dc2e5fa59c7cc8916fca3bccb637dd5e583931930f6b4e0a22b961ee71058f518a090c0a636da8147b999acdaa06cd2fc3ee51c  cloud-init-20.2.tar.gz
4ab37323e7662445af90ce2654199fe3080e256571e8e12b121ebde791b98e68d368b10c5f22b7e8840c0ba9593dd0a6e37ec60724cd0ae4c806944a826741e3  01-add-distro-alpine.patch
5b6cba9da22c1b8d202170f215995abe22100251dee705219607cdadf32de498a3af56aab8324254f755ef0caa22f6a4e9fdcf8fc53dc4fde6757957a266405e  02-add-to-util.patch
236862f50c841704750109a1e4fe985bec6501554d8da33e1103fe35795c2ee566ae8d6b79cc2ec09160ec614fa61c09f1a778dea85d0e5e1ecb487d5f0d7fa0  03-add-to-cloud-cfg-template.patch
d92ea4aaf811a7338348054d8438051cf3f6a11e92b976f3b7c4d976f64de3144c97ec3c44a5691299eb499d0089b5a484a31bfa3d826fb44643185a76502c64  04-add-to-render-cloudcfg.patch
15ce19f650c145cba57286ac6138dbc48fc7923e29d8ff0b9acd443b5bb74896676c1ecdca67a2a706332be3e0621ec347defbe926c3541d4f6529554204ca47  05-add-ca_certs-module-support.patch
8f7c52c493409bb2c82be88c623e5d75c8bea3b9b37fa4da8967ec25670ea47d236dff3ac3e0373304175e1ac3e8b1a9182ae6e9ffd601ab7a9e6f4367170524  06-add-ntp-module-support.patch
e93cd17971cd890d938a7db1af805edf944d34048ca222bfda9bb8b81626a196b51e0c2fdc048d83ff562e912d44f4670341867bcb87b760a354ca4dc2d9542a  07-add-power_state-module-support.patch
2871a0adfa70df2101b292829dc13f2b8a894b851b27d8f2579e3aebc598b849166f4dee9e27d0fda8680421f546c371c05a3526ea54606806bc288a95939ccc  08-add-resolv_conf-module-support.patch
659dd1a094074be1870e471469d227fe5b41334766816bc88fd0ed42153fdb4eb53248565a17021ad10565d73747d806bed8f6aa2a7681bb1d1ef096df6b9746  alpine.py
3484432f4b577ece2c26657b5c5f48e1fd184ea7a1bef67ef111df0e76d9fe2c17031150be37cd88d3097d1a7a5d08309dfcd372788aae7e38389f5ac3ce1eec  cc_apk_configure.py
f671ce6e54b8c6a1e3a1bd47fe93d380b1d12906be88891f00ee6e1f789bdc0ed38a777664cb1b7d6618a73e1dce47ee4f30d0831334f3bd3274aed11f063de4  chrony.conf.alpine.tmpl
9b009f83ff739bab9ceeb653fb41f6d42b562bdf0fbc67bf42bff53f903fc0da5dda1cf10375c0f94fbf086f3710620bf0302d1c9bec2d39abfd0cb737bc6e42  hosts.alpine.tmpl
48b25ec4457c2b3772a7d210033551d041749a0d1869818d888030e6df7fd9bbc13a38b95cf465de3d46d96881a722f94a337584ce48f280c4a52b819586563a  interfaces
bcba9a8da0c9c6dcd318fc67635e56847a8b94f61cc5b494464dfda51d21dbde56de32ba5573047c63522bf19e77a1be483c2dfbaeec0844e8fc75a160ff3a5e  ntp.conf.alpine.tmpl"
